#!/usr/bin/perl
# diskswap.cgi in diskman

require './diskman-lib.pl';
&error_setup("abc");
#&error();
&ReadParse();
$diskindex = $in{'disk'};
if ($diskindex =~ /^(\d+)/) {
    $nn = $1;
}
@disks = get_all_lsi_diskinfo(); 
if ($diskindex =~ /(\d+)/) {
    $dnum = $1;
}
$des = $disks[$dnum]->{'es'};
$uid = $disks[$dnum]->{'status'};
#&error($des);
if( $uid =~ /Hotspare/ ) {
    system("/sbin/MegaCli -PDHSP -Rmv -PhysDrv[$des] -a0");
}
elsif ($uid =~ /good/) {
    system("/sbin/MegaCli -PDHSP -Set -PhysDrv[$des] -a0");

}

&redirect("index.cgi");


